/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package podologia.beansDB;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author Hernan
 */
@Entity
@Table(name = "trataxpatologia")
@NamedQueries({@NamedQuery(name = "Trataxpatologia.findAll", query = "SELECT t FROM Trataxpatologia t"), @NamedQuery(name = "Trataxpatologia.findByIdTrataPato", query = "SELECT t FROM Trataxpatologia t WHERE t.idTrataPato = :idTrataPato")})
public class Trataxpatologia implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    @Basic(optional = false)
    @Column(name = "idTrataPato")
    private Integer idTrataPato;
    @JoinColumn(name = "idTratamieto", referencedColumnName = "idTratamiento")
    @ManyToOne(optional = false)
    private Tratamiento idTratamieto;
    @JoinColumn(name = "idPatologia", referencedColumnName = "idPatologia")
    @ManyToOne(optional = false)
    private Patologia idPatologia;

    public Trataxpatologia() {
    }

    public Trataxpatologia(Integer idTrataPato) {
        this.idTrataPato = idTrataPato;
    }

    public Integer getIdTrataPato() {
        return idTrataPato;
    }

    public void setIdTrataPato(Integer idTrataPato) {
        Integer oldIdTrataPato = this.idTrataPato;
        this.idTrataPato = idTrataPato;
        changeSupport.firePropertyChange("idTrataPato", oldIdTrataPato, idTrataPato);
    }

    public Tratamiento getIdTratamieto() {
        return idTratamieto;
    }

    public void setIdTratamieto(Tratamiento idTratamieto) {
        Tratamiento oldIdTratamieto = this.idTratamieto;
        this.idTratamieto = idTratamieto;
        changeSupport.firePropertyChange("idTratamieto", oldIdTratamieto, idTratamieto);
    }

    public Patologia getIdPatologia() {
        return idPatologia;
    }

    public void setIdPatologia(Patologia idPatologia) {
        Patologia oldIdPatologia = this.idPatologia;
        this.idPatologia = idPatologia;
        changeSupport.firePropertyChange("idPatologia", oldIdPatologia, idPatologia);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idTrataPato != null ? idTrataPato.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Trataxpatologia)) {
            return false;
        }
        Trataxpatologia other = (Trataxpatologia) object;
        if ((this.idTrataPato == null && other.idTrataPato != null) || (this.idTrataPato != null && !this.idTrataPato.equals(other.idTrataPato))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return idTratamieto.getNombre();
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }

}
